package controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HttpServletBean;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import service.FlightService;

public class HomePageController extends AbstractController {

	private int FIVE_MINUTES = 5 * 60;
	private FlightService flightService;

	// --- Getters,Setters,Constructors ----------------------------------------
	public HomePageController() {
		setSupportedMethods(new String[] { METHOD_GET });
		setCacheSeconds(FIVE_MINUTES);
	}

	public void setFlightService(FlightService flightService) {
		this.flightService = flightService;
	}

	// --- Methods -------------------------------------------------------------
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = new ModelAndView("home");
		modelAndView.addObject("specialDeals", flightService.getSpecialDeals());
		return modelAndView;
	}

}
